<template>
  <view class="hb-px-6 hb-mt-25">
    <view class="hb-flex hb-flex-col hb-items-center hb-justify-center">
      <!-- <image class="hb-w-20 hb-h-20 hb-mb-6" src="@/static/icon/logo.png" /> -->
      <text class="hb-text-dark-300 hb-text-2xl">{{ appStore.appName }}</text>
    </view>
    <view class="hb-mt-40">
      <TmButton
        :loading="loading"
        :block="true"
        size="large"
        color="#07C160"
        :follow-theme="false"
        label="手机号快捷登录"
        open-type="getPhoneNumber"
        @getphonenumber="getPhoneNumber"
      />
    </view>
  </view>
</template>

<script setup lang="ts">
  import { ThridTypeEnum } from '@/enums/LoginEnum';
  import { useUserStore } from '@/store/modules/user';
  import { Toast } from '@/utils';
  import { useAppStore } from '@/store/modules/app';

  const emits = defineEmits(['navBack']);

  const loading = ref(false);
  const useUser = useUserStore();
  const appStore = useAppStore();

  function getPhoneNumber({ detail: { code, iv, encryptedData, errno } }: any) {
    if (unref(loading)) return;
    loading.value = true;
    if (errno === 1400001) {
      Toast('手机号快捷登录受限,请联系管理员处理');
      return;
    }
    if (!iv || !encryptedData) return;
    // useUser
    //   .getPhoneNumber({ code, iv, encryptedData, thridType: ThridTypeEnum.MINIAPP })
    //   .then((res) => {
    //     emits('navBack');
    //   })
    //   .catch((err) => {
    //     loading.value = false;
    //   });
  }
</script>

<style scoped></style>
